﻿@model HQPad.Models.Skill

@{
    int ruleSetId = (int) ViewBag.RuleSetID;
    string spellLevelBonus = ViewBag.SpellLevelBonus as string;
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

<h1>Create skill</h1>

@section PageScripts {
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
}
<section class="content">

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset class="block form form-wide-label">
        <legend>Basics</legend>

            <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.Name)
        </div>
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        @Html.Hidden("Deleted", "false")
        @Html.Hidden("RuleSetID", ruleSetId.ToString())

            <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.MaxRanks)
        </div>
            @Html.EditorFor(model => model.MaxRanks)
            @Html.ValidationMessageFor(model => model.MaxRanks)
        </div>

            <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.IsBasic)
        </div>
            @Html.EditorFor(model => model.IsBasic)
            @Html.ValidationMessageFor(model => model.IsBasic)
        </div>

            <div class="field-item">
        <div class="label">
            @Html.LabelFor(model => model.TypeOfSkill)
        </div>
            @Html.DropDownList("TypeOfSkill")
            @Html.ValidationMessageFor(model => model.TypeOfSkill)
        </div>

        <div class="editor-field">
            <table style="width: 100%">
                <tr>
                    <th>Table</th>
                    <th>Cost</th>
                    <th>Modifier</th>
                    <th>Rank multiplied</th>
                </tr>
                <tr>
                    @{
    int cnt = 0;
    List<HQPad.Models.PointsTable> tables = ViewBag.Tables;

    foreach (var table in tables)
    {
        if (cnt++ % 1 == 0)
        {
                        @:  </tr> <tr> 
                    }
                    @: <td> 
                                @table.Race @:&nbsp; @table.Class
                            @:</td>
                            @: <td> 
                                <input type="text" 
                                    @(Html.Raw("name=\"cost_" + @table.PointsTableID + "\""))
                                    value="0"
                                    class="text-box-small" /> 
                            @:</td>
                            @: <td> 
                                <input type="text" 
                                    @(Html.Raw("name=\"mod_" + @table.PointsTableID + "\""))
                                    value="0"
                                    class="text-box-small" /> 
                            @:</td>
                            @: <td> 
                                <input type="checkbox" 
                                       @(Html.Raw("name=\"mul_" + @table.PointsTableID + "\""))
                                       value="@table.PointsTableID" 
                                    class="text-box-small" /> 
                            @:</td>
                        }
                        @: </tr>
                    }
            </table>
        </div>
    </fieldset>
    
    <fieldset class="block form form-wide-label">
        <legend>Bonus</legend>

            <div class="field-item">
        <div class="label"><label for="armouredDex">Armoured Dex</label></div>
            @Html.CheckBox("armouredDex", Request.Form["armouredDex"] != null ? Request.Form["armouredDex"].Contains("true") : false)
        </div>

            <div class="field-item">
        <div class="label"><label for="unarmouredDex">Unarmoured Dex</label></div>
            @Html.CheckBox("unarmouredDex", Request.Form["unarmouredDex"] != null ? Request.Form["unarmouredDex"].Contains("true") : false)
        </div>        

            <div class="field-item">
        <div class="label"><label for="physAc">Physical AC</label></div>
            @Html.CheckBox("physAc", Request.Form["physAc"] != null ? Request.Form["physAc"].Contains("true") : false)
        </div>        

            <div class="field-item">
        <div class="label"><label for="magAc">Magical AC</label></div>
            @Html.CheckBox("magAc", Request.Form["magAc"] != null ? Request.Form["magAc"].Contains("true") : false)
        </div>        

            <div class="field-item">
        <div class="label"><label for="powAc">Power AC</label></div>
            @Html.CheckBox("powAc", Request.Form["powAc"] != null ? Request.Form["powAc"].Contains("true") : false)
        </div>        

            <div class="field-item">
        <div class="label"><label for="lifeRank">Life Rank</label></div>
            @Html.CheckBox("lifeRank", Request.Form["lifeRank"] != null ? Request.Form["lifeRank"].Contains("true") : false)
        </div>        

            <div class="field-item">
        <div class="label"><label for="spellLevel">Level of Spell</label></div>
            @Html.DropDownList("spellLevel", new SelectList(new List<string>() { "none", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }, spellLevelBonus))
        </div>        

            <div class="field-item">
        <div class="label"><label for="invocations">Learn invocations</label></div>
            @Html.CheckBox("invocations", Request.Form["invocations"] != null ? Request.Form["invocations"].Contains("true") : false)
        </div>        

            <div class="field-item">
        <div class="label"><label for="spells">Learn spells</label></div>
            @Html.CheckBox("spells", Request.Form["spells"] != null ? Request.Form["spells"].Contains("true") : false)
        </div>        

            <div class="field-item">
        <div class="label"><label for="power">Extra power</label></div>
            @Html.CheckBox("power", Request.Form["power"] != null ? Request.Form["power"].Contains("true") : false)
        </div>        

            <div class="field-item">
        <div class="label"><label for="quantity">Quantity</label></div>
            @Html.TextBox("quantity", "1")
        </div>        
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div class="block">
    @Html.ActionLink("Back to List", "Index", null, new { @class="button" })
</div>

</section>